#include <iostream>

class Fruit
{
public:
    virtual void show() = 0;
};

class NorthApple:public Fruit
{
public:
    void show()
    {
        std::cout<<"北方苹果"<<std::endl;
    }
};

class NorthPear:public Fruit
{
public:
    void show()
    {
        std::cout<<"北方梨"<<std::endl;
    }
};

class SouthApple:public Fruit
{
public:
    void show()
    {
        std::cout<<"南方苹果"<<std::endl;
    }
};
class SouthPear:public Fruit
{
public:
    void show()
    {
        std::cout<<"南方梨"<<std::endl;
    }
};
class Factory
{
public:
    virtual Fruit* CreateApple() = 0;
    virtual Fruit* CreatePear() = 0;
};

class SouthFactory:public Factory
{
public:
    Fruit* CreateApple()
    {
        return new SouthApple;
    }
     Fruit* CreatePear()
    {
        return new SouthPear;
    }
};

class NorthFactory:public Factory
{
public:
    Fruit* CreateApple()
    {
        return new NorthApple;
    }
    Fruit* CreatePear()
    {
        return new NorthPear;
    }
};


int main()
{
    Factory *f = new NorthFactory;
    f->CreateApple()->show();
    f->CreatePear()->show();
}